Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
vue3 blocks tree does not "reload" when changing the data

I am looking for a organization chart plugin for vue 3 and I have found only this one

https://github.com/megafetis/vue3-blocks-tree

The issue that I have is when changing the ref treeData variable the chart is not loading the new structure.

I want to dynamic load the chart. When fetch the data the chart to loads the new data and display it.

Here is the codesandbox example:

https://codesandbox.io/s/flamboyant-gwen-o8vp9?file=/src/App.vue

When press the Add ... the treeData reference variable should load the new data and the chart to display it ... but it doesn't.

Any ideas ?

Should I reload the component on every fetch ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try to use documented way make treeData reactive.

Replace ref to reactive for treeDate definition. Change parts of treeData on onAddData instead replacing all object.

Full changed example:

import { reactive } from "vue";
import VueBlocksTree from "vue3-blocks-tree";
import "vue3-blocks-tree/dist/vue3-blocks-tree.css";

export default {
  name: "Diagram",
  components: { VueBlocksTree },
  setup() {
    let treeData = reactive({
      label: "root",
      children: [
        { label: "child 1" },
        { label: "child 2" },
        {
          label: "subparent 1",
          children: [
            { label: "subchild 1" },
            {
              label: "subchild 2",
              children: [{ label: "subchild 11" }, { label: "subchild 22" }],
            },
          ],
        },
      ],
    });

    // let treeData = ref({});

    const onAddData = () => {
      Object.assign(treeData, { label: "Test", children: [{ label: "Test 1" }, { label: "Test 2" }] });
    };

    return {
      treeData,
      onAddData,
    };
  },
};

UPD: Change code on onAddData by adding Object.assign.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda